# -*- coding: utf-8 -*-
# created by Src - 一路好时光

names = {
 "alex": [23, "CEO", 66000],
 "⿊姑娘": [24, "⾏政", 4000],
}
print(names)#{'alex': [23, 'CEO', 66000], '⿊姑娘': [24, '⾏政', 4000]}

#新增
names["佩奇"] = [26,"讲师", 40000]
print(names)#{'alex': [23, 'CEO', 66000], '⿊姑娘': [24, '⾏政', 4000], '佩奇': [26, '讲师', 40000]}

#删除
print(names.pop("alex"))#[23, 'CEO', 66000]
del names['⿊姑娘']
print(names)#{'佩奇': [26, '讲师', 40000]}
#清空
names.clear()
print(names)#{}

#修改
names = {
 "alex": [23, "CEO", 66000],
 "⿊姑娘": [24, "⾏政", 4000],
}

#查操作
names["alex"] = [28, "CEO2", 66000]
print(names)#{'alex': [28, 'CEO2', 66000], '⿊姑娘': [24, '⾏政', 4000]}
print(names['alex'])#[24, '⾏政', 4000]
print('alex' in names)#True  如果是中文可能出错
print('⿊姑娘' in names)#True
print(names.keys())#dict_keys(['alex', '⿊姑娘'])
#TypeError: 'builtin_function_or_method' object is not iterable
for k in names.keys():
 print(k)
#alex
#⿊姑娘

for v in names.values():
 print(v)
#[28, 'CEO2', 66000]
#[24, '⾏政', 4000]

for k,v in names.items():
 print(k,v)
#alex [28, 'CEO2', 66000]
#⿊姑娘 [24, '⾏政', 4000]

#循环
for k in names:
 print(k,names[k])
#alex [28, 'CEO2', 66000]
#⿊姑娘 [24, '⾏政', 4000]

#求长度 解释器自带的函数
print(len(names))#2

names["src"]={"name":"时","age":23}
print(names)#{'alex': [28, 'CEO2', 66000], '⿊姑娘': [24, '⾏政', 4000], 'src': {'name': '时', 'age': 23}}
print(names["src"]["name"])#时
